package com.zq.assistant.mgr.path;

import android.os.Environment;

import com.zq.assistant.app.App;
import com.zq.assistant.utils.FileUtils;

import java.io.File;

/**
 * Created by zhangqiang on 17-6-15.
 */

public class PathManager extends BasePathManager {

    private static final PathManager instance = new PathManager();

    public static PathManager get() {
        return instance;
    }

    private PathManager() {
    }

    @Override
    public File getBaseDir() {

        if (FileUtils.isSdCardAvailable()) {

            return makeDirIfNeed(new File(Environment.getExternalStorageDirectory(), App.instance.getPackageName()));
        } else {

            return App.instance.getFilesDir();
        }
    }

    @Override
    public File getCacheDir() {

        if (FileUtils.isSdCardAvailable()) {

            return makeDirIfNeed(new File(getBaseDir() , "cache"));
        }else{

            return App.instance.getCacheDir();
        }
    }
}
